import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserMessageVO, UserMessageForm, UserMessageQuery } from '@/api/userMessage/userMessage/types';

/**
 * 查询用户消息列表
 * @param query
 * @returns {*}
 */

export const listUserMessage = (query?: UserMessageQuery): AxiosPromise<UserMessageVO[]> => {
  return request({
    url: '/userMessage/userMessage/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户消息详细
 * @param id
 */
export const getUserMessage = (id: string | number): AxiosPromise<UserMessageVO> => {
  return request({
    url: '/userMessage/userMessage/' + id,
    method: 'get'
  });
};

/**
 * 新增用户消息
 * @param data
 */
export const addUserMessage = (data: UserMessageForm) => {
  return request({
    url: '/userMessage/userMessage',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户消息
 * @param data
 */
export const updateUserMessage = (data: UserMessageForm) => {
  return request({
    url: '/userMessage/userMessage',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户消息
 * @param id
 */
export const delUserMessage = (id: string | number | Array<string | number>) => {
  return request({
    url: '/userMessage/userMessage/' + id,
    method: 'delete'
  });
};
